package k.user.controller;


import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserController {
    @GetMapping("user")
    public String getUser(HttpServletRequest request) {
        return "user"+request.getServerPort();
    }
    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("work_queue")
    public String test一对多消费(String msg) {
        String queueName = "workQueue";
        for (int i = 0; i < 20; i++) {
            rabbitTemplate.convertAndSend(queueName, msg + i);
        }
        return "一对多消费 => 生产OK";
        }
}
